package com.zhisheng.result;
/*
    全哥
*/

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class MyResponseResult<T> {
    private Integer code;
    private String msg;
    private T data;

    public static <T> MyResponseResult<T> success(T data) {
        return new MyResponseResult<>(200, "success", data);
    }

    public static <T> MyResponseResult<T> success(Integer code, T data) {
        return new MyResponseResult<>(code, "success", data);
    }

    public static <T> MyResponseResult<T> success(Integer code, String msg, T data) {
        return new MyResponseResult<>(code, msg, data);
    }

    public static <T> MyResponseResult<T> fail(Integer code, String msg) {
        return new MyResponseResult<>(code, msg, null);
    }

    public static <T> MyResponseResult<T> fail(String msg) {
        return new MyResponseResult<>(500, msg, null);
    }

    public static <T> MyResponseResult<T> fail() {
        return new MyResponseResult<>(500, "fail", null);
    }
}